#!/usr/bin/env python3
# -*- coding:utf-8 -*-
from tkinter import Frame, Label, Button, Entry
import tkinter.messagebox as messagebox


# grid实现更复杂的界面
class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets2()

    def createWidgets(self):
        self.helloLabel = Label(self, text='Hello, Wolld!')
        self.helloLabel.pack()
        self.quitButton = Button(self, text="quit", command=self.quit)
        self.quitButton.pack()

    def createWidgets2(self):
        self.nameInput = Entry(self)
        self.nameInput.pack()
        self.alertButton = Button(self, text="确认", command=self.hello)
        self.alertButton.pack()

    def hello(self):
        name = self.nameInput.get() or "world"
        messagebox.showinfo("message", "你好，%s" % name)


if __name__ == '__main__':
    application = Application()
    application.master.title("第一个ui")
    application.mainloop()
